package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.Map;
import java.util.function.UnaryOperator;

/**
 * @Description TODO
 * @Author itheima
 * @Date 2023-07-17 17:36
 */
@Mapper
public interface UserMapper {
    /**
     * 根据iopenid查询用户
     * @param openid
     * @return
     */
    @Select("select * from user where  openid=#{openid}")
     User getByUser(String openid) ;

    /**
     * 添加用户
     * @param user
     */
    @Insert("insert into user (id, openid, name, phone, sex, id_number, avatar, create_time) values" +
            "(null,#{openid} ,#{name},#{phone},#{sex},#{idNumber},#{avatar},#{createTime})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    void insertUser(User user);

    /**
     * 根据id查询用户
     * @param id
     * @return
     */
    @Select("select * from user where id=#{id}")
    User getByUserId(Long id);

    /**
     * 统计每天新增用户
     * @param map
     * @return
     */
    Integer countByMap(Map map);


}
